/**
 * @Author: yy
 * @Date: 2019/6/20
 * @Last Modified by: mikey.zhaopeng
 * @Last Modified time: 2019-12-19 16:39:05
 */
import axios from '@/api/fetch';
import * as types from './types';
import SERVER from '@/api/server';
// 查询城市列表
export const queryCityList = params => axios.get(`${SERVER.BASEDATA}/region/listAllRegionData`, { params });
// 获取意向级别
export const getIntentLevelsList = params => axios.get(`${SERVER.CYXDMS_CLUE}/potenCusManage/intentLevel?basedataType=1611&basedataName=70661001`, { params });
//  查询线索信息
export const queryPotenCusManage = params => axios.get(`${SERVER.CYXDMS_CLUE}/clue/clueMarkftinhView`, { params });
//  查询接触记录
export const queryContactRecord = (id, ownerCode) => axios.get(`${SERVER.CYXDMS_CLUE}/potenCus/queryContactRecordList/?customerBusinessId=${id}&shardingOwnerCode=${ownerCode}`);
//  查询接触记录20191204
export const queryPlateContactRecordList = (potentialCustomerId, customerBusinessId, ownerCode) => axios.get(`${SERVER.CYXDMS_CLUE}/potenCus/queryPlateContactRecordList?potentialCustomerId=${potentialCustomerId}&customerBusinessId=${customerBusinessId}&shardingOwnerCode=${ownerCode}`);

//  查询相关线索
export const queryAboutClues = (mobilePhone, customerBusinessId, ownerCode, params) => axios.get(`${SERVER.CYXDMS_CLUE}/potenCus/queryRelateClueList/?mobilePhone=${mobilePhone}&customerBusinessId=${customerBusinessId}&shardingOwnerCode=${ownerCode}`, { params });
//  根据潜客ID查询销售订单接触记录
// export const queryOrderRecord = id => axios.get(`${SERVER.CYXDMS_RETAIL}/ordermanage/salesOrders/salesOrderHistory/${id}`);
export const queryOrderRecord = {};
//  根据潜客ID查询回访记录
// export const queryVisitHsitory = id => axios.get(`${SERVER.CYXDMS_CUSTOMERCARE}/careTask/careTasks/queryVisitHsitory?customerBusinessId=${id}`);
export const queryVisitHsitory = {};
//  查询销售顾问/网销顾问
export const queryEmployees = params => axios.get(`${SERVER.CYXDMS_CLUE}/clue/employeeList`, { params });
//  新增线索潜客
export const addNewLeads = params => axios.post(`${SERVER.CYXDMS_CLUE}/potenCus/insertPotenCus`, params);
//  线索潜客编辑保存
export const updateNewLeads = params => axios.put(`${SERVER.CYXDMS_CLUE}/potenCus/updatePotenInfo`, params);
//  线索跳转编辑页面
// export const getPotenCusById = (id, clueType="") => axios.get(`${SERVER.CYXDMS_CLUE}/potenCus/potentialCustomerDetail?potentialCustomersId=${id}&clueType=${clueType}`, { id: Number(id) });
export const getPotenCusById = (id, clueType = "", ownerCode) => axios.get(`${SERVER.CYXDMS_CLUE}/potenCus/potentialCustomerDetail?potentialCustomersId=${id}&clueType=${clueType}&shardingOwnerCode=${ownerCode}`, { id: Number(id) });
//  线索来源接口
export const getClueSources = (params, id) => axios.put(`${SERVER.CYXDMS_CLUE}clue/clueSource/${id}/${dataType}`, params);
// 获取车型数据
// export const getAllModal = appId => axios.get(`${SERVER.BASEDATA}/vehicleProduct/open/getAllModel?appId=${appId}`);
export const getAllModal = params => axios.get(`${SERVER.BASEDATA}/vehicleProduct/productInfo/productTree?isUnlimited=10041001`, { params });

// 获取内饰颜色
export const getAllColorByAppIdAndType = params => axios.get(`${SERVER.BASEDATA}/color/getAllColorByAppIdAndType`, { params });

// 获取顾问列表
// export const getSalesName = params => axios.get(`${SERVER.SYSMANAGE}/basedata/employees/getDirSalesName`, { params });  /api/sysManage/basedata/users/getUsersByPosition?positionCodes=10061015&menuId=
export const getConsultantName = params => axios.get(`${SERVER.SYSMANAGE}/basedata/users/getUsersByPosition`, { params });
// 获取购车因素
export const getCarBuyingFactor = params => axios.get(`${SERVER.CYXDMS_CLUE}/customerManage/carBuyingFactor/queryAllByCarFactors`, { params });
// 获取了解途径
export const getKnowWays = params => axios.get(`${SERVER.CYXDMS_CLUE}/potenCus/getInfoWays`, { params });

// 保存分配顾问
export const saveConsultantName = params => axios.post(`${SERVER.CYXDMS_CLUE}/clue/clueDistributionMarkete`, params);
// 查询变更历史
export const queryChangeList = (id, ownerCode) => axios.get(`${SERVER.CYXDMS_CLUE}/potenCus/queryClueChangeList/?customerBusinessId=${id}&shardingOwnerCode=${ownerCode}`);
// 获取线索来源树
export const queryClueSourceList = params => axios.get(`${SERVER.CYXDMS_CLUE}/basedata/clueSource/queryTreeSource`, { params });
// 获取所有线索来源树
export const queryTreeSourceAll = params => axios.get(`${SERVER.CYXDMS_CLUE}/basedata/clueSource/queryTreeSourceAll`, { params });
// 查询竞品品牌
export const getJPBrands = params => axios.get(`${SERVER.CYXDMS_CLUE}/basedata/failModels/getBrand`, { params });
// 查询竞品车系
export const getJPSeries = (failModelId, params) => axios.get(`${SERVER.CYXDMS_CLUE}/basedata/failModels/getSeriesByBrandId?failModelId=${failModelId}`, { failModelId: failModelId, params: params });

// 查询经销商代码   通过组织类型获取下面的组织
export const getOrgType = orgType => axios.get(`${SERVER.SYSMANAGE}/org/getOrgByOrgType?orgType=${orgType}`);
//查询小区
export const getOrgTypeForMin = (parentOrgId, orgType) => axios.get(`${SERVER.SYSMANAGE}/org/org/${parentOrgId}/${orgType}`);
// 大小区下面查询公司
export const getDealerArea = (id, dealerCode, dealerName) => axios.get(`${SERVER.SYSMANAGE}/company/org/getDealerBySaleArea?orgId=${id}&dealerCode=${dealerCode}&dealerName=${dealerName}`, { id: Number(id) });
/**
 * 车厂通过组织id（大区小区类型的组织）获取本车厂下对应的经销商
 * isDisArea： 10041001 只有大区   10041002 ：有小区
 * isMerge ：10041001 销售售后合并  10041002 ：不合并
 */
export const getCompanyOrgIsMerge = params => axios.get(`${SERVER.SYSMANAGE}/company/org/getMerge`, { params });

// 北汽下单保存
export const saveBeijing = params => axios.get(`${SERVER.CYXDMS_CLUE}/potentialCustomerBQ/updatePotenInfoById`, { params });

// 获取所有线索热度级别定义
export const getAllHeatUp = params => axios.get(`${SERVER.CYXDMS_CLUE}/basedata/clueHeatSetup/getAllHeatUp`, { params });
// 非活跃潜客输入手机号码带出潜客信息   0:不存在 1:本人潜客 2:其他顾问潜客 3:战败潜客 4:成交潜客
export const getActivePhoneInfo = mobilePhone => axios.get(`${SERVER.CYXDMS_CLUE}/clue/clueCheckRepetition?mobilePhone=${mobilePhone}`, { mobilePhone: mobilePhone });
// 查重接口返回4  跳转到新增界面  根据商机id查询回显数据
export const getOrderInfo = costomerBusinessId => axios.get(`${SERVER.CYXDMS_CLUE}/potenCus/customerInfoById?costomerBusinessId=${costomerBusinessId}`, { costomerBusinessId: costomerBusinessId });
// 展厅建档保存处理
export const updateDisposeStatusById = params => axios.get(`${SERVER.CYXDMS_CLUE}/receptionist/updateDisposeStatusById?id=${params.id}&operation=${params.operation}`);


//客档管理导出
export const getPotenCusManageExcelList = params => {
  params = Object.assign(params, { menuId: '-1' });
  return axios({
    url: `${SERVER.CYXDMS_CLUE}/clue/export/excel`,
    method: 'get',
    params: params,
    responseType: 'blob'
  });
};
